#define _CRT_SECURE_NO_WARNINGS 1

string multiply(string num1, string num2) {
    constexpr const int thousand{ 1000 };
    int a[thousand], b[thousand], c[thousand];
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    memset(c, 0, sizeof(c));
    int lena{ (int)num1.length() }, lenb{ (int)num2.size() }, i, j, x;
    for (i = 0; i <= lena - 1; ++i) a[lena - i] = num1[i] - '0';
    for (i = 0; i <= lenb - 1; ++i) b[lenb - i] = num2[i] - '0';
    for (i = 1; i <= lena; ++i) {
        x = 0;
        for (j = 1; j <= lenb; ++j) {
            c[i + j - 1] = a[i] * b[j] + x + c[i + j - 1];
            x = c[i + j - 1] / 10;
            c[i + j - 1] %= 10;
        }
        c[i + lenb] = x;
    }
    int lenc{ lena + lenb };
    while (c[lenc] == 0 && lenc > 1) --lenc;
    string result{ "" };
    for (i = lenc; i >= 1; --i) result += c[i] + '0';
    return result;
}